//
//  WelcomeViewController.swift
//  WB
//
//  Created by leador on 17/4/7.
//  Copyright © 2017年 袁满. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var bgView: UIImageView!
    @IBOutlet weak var iconViewBottomCons: NSLayoutConstraint!
    
    @IBOutlet weak var iconView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let profileUrl = UserAccountViewModel.shareInstance.account?.avatar_hd
        //?? 如果前面的可选类型有值，那么将前面的可选类型进行解包并赋值，如果前面的可选类型为nil则使用？？后面的值赋值
        guard let url = URL(string:profileUrl ?? "") else {
            return
        }
            
        iconView.sd_setImage(with: url, placeholderImage: #imageLiteral(resourceName: "avatar_default_big"))
        
        //Damping: 阻力系数越大，弹动的效果越不明显（0-1）
        //initialSpringVelocity 初始化速度
        //[]  枚举值
        self.iconViewBottomCons.constant = kScreenHeight - 200
        
        UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 5.0, options: [], animations: {
            self.view.layoutIfNeeded()
        }) { (_) in
            UIApplication.shared.keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle:nil).instantiateInitialViewController()
        }

    }

}
